import React, { Component, Fragment} from 'react'
import PropTypes from 'prop-types'

class List extends Component{
    constructor(props){
        super(props)
    }
    render(){
        return (
            <Fragment>
                <ul>
                    {
                        this.props.data.map((item,idx)=>{
                            return (
                                <li key={item + idx} onClick={this.delHandleFun.bind(this,idx)}>{item}</li>
                            )
                        })
                    }
                </ul>
            </Fragment>
        )
    }
    delHandleFun(idx){
        this.props.delFun(idx);
    }
}
List.propTypes = {
    data:PropTypes.array,
    delFun:PropTypes.func.isRequired
}
export default List